package com.zmn.brs.services.impl.blacklist;

import java.util.Objects;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
import com.zmn.brs.model.entity.blacklist.BlacklistConfig;
import com.zmn.brs.persistence.interfaces.blacklist.BlacklistConfigDao;
import com.zmn.brs.services.interfaces.blacklist.BlacklistConfigService;

/**
 * 描述:
 *
 * @author wangjie
 * @since 2019/8/5
 **/
@Service
public class BlacklistConfigServiceImpl implements BlacklistConfigService {

    private BlacklistConfigDao blacklistConfigDao;

    @Autowired
    public BlacklistConfigServiceImpl(BlacklistConfigDao blacklistConfigDao) {
        this.blacklistConfigDao = blacklistConfigDao;
    }

    /**
     * 描述: 根据时间类型查询数据
     *
     * @param timeType
     *            时间类型
     * @return com.zmn.plat.model.entity.blacklist.BlacklistConfig
     * @author wangjie
     * @since 2019/8/5
     **/
    @Override
    @ReadOnlyConnection
    @Cacheable(cacheNames = "redis5m", key = "'blacklist:child:timeType:'+#p0")
    public BlacklistConfig findByTimeType(Integer timeType) {

        if (Objects.isNull(timeType)) {
            throw new NullPointerException("timeType不能为null");
        }
        return blacklistConfigDao.findByTimeType(timeType);
    }
}
